package com.ex.mzwqz.activity;

import android.view.View;
import android.widget.AdapterView;

import com.ex.mzwqz.R;
import com.ex.mzwqz.adapter.CheckAdapter;
import com.ex.mzwqz.model.CheckEntity;
import com.ex.mzwqz.util.Constants;
import com.ex.mzwqz.util.UiManager;
import com.limxing.xlistview.view.XListView;

import java.util.List;

/**
 * Created by xiaguoqiang on 16/10/23.
 */
public class CheckActivity extends BaseActivity implements XListView.IXListViewListener {

    private XListView lvChecks;
    private CheckAdapter adtCheck;
    private int checkStatus;

    @Override
    protected int setContentViewResId() {
        return R.layout.activity_check;
    }

    @Override
    protected void initView() {
        checkStatus = getIntent().getIntExtra(Constants.REQUEST_TYPE_CHECK_STATUS,Constants.SYS_CHECK_STATUS_PRELIMINARY);
        switch (checkStatus){
            case Constants.SYS_CHECK_STATUS_PRELIMINARY:
                setTitle("初审管理");
                break;
            case Constants.SYS_CHECK_STATUS_CHECK:
                setTitle("审核管理");
                break;
            case Constants.SYS_CHECK_STATUS_CHECKED:
                setTitle("牌照管理");
                break;
            case Constants.SYS_CHECK_STATUS_YEAR:
                setTitle("年审管理");
                break;
            case Constants.SYS_CHECK_STATUS_CHANGE:
                setTitle("变更管理");
                break;
        }
        lvChecks = (XListView) findViewById(R.id.lv_refresh_check);
        lvChecks.setPullRefreshEnable(true);
        lvChecks.setPullLoadEnable(true);
        lvChecks.setXListViewListener(this);
        adtCheck = new CheckAdapter(this, R.layout.item_check);
        lvChecks.setAdapter(adtCheck);
    }

    @Override
    protected void initData() {
        getTest();
    }

    public void  getTest(){
        adtCheck.add(new CheckEntity("11671","沙依巴克区扬子江路厚粮酸菜牛肉面馆"));
        adtCheck.add(new CheckEntity("11670","沙依巴克区克拉玛依东街北巷米拉吉友好路餐厅"));
        adtCheck.add(new CheckEntity("11669","新疆永升嘉轩食品股份有限公司乌鲁木齐第一分公司有限责任公司"));
        adtCheck.add(new CheckEntity("11668","乌鲁木齐市沙依巴克区新宏运鲍翅阁"));
        adtCheck.add(new CheckEntity("11667","新疆友好（集团）股份有限公司友好大酒店股份有限公司分公司"));
        adtCheck.add(new CheckEntity("11666","新疆古德食品有限公司"));
        adtCheck.add(new CheckEntity("11665","沙依巴克区仓房沟路帝克利食品加工厂"));
    }

    @Override
    protected void initEvent() {
        lvChecks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                UiManager.toWebView(CheckActivity.this,"审批处理",Constants.CHECK_BASE_URL + adtCheck.getItem(i - 1).getId());
            }
        });
    }

    @Override
    public void onRefresh() {
        lvChecks.stopRefresh();
    }

    @Override
    public void onLoadMore() {
        lvChecks.stopLoadMore();
    }
}
